FROM golang:1.19.4-alpine as build
WORKDIR /usr/src/app
COPY . .
RUN go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
RUN GOOS=linux GOARCH=amd64 go mod tidy && go build -v -o /tmp/app


FROM alpine:3.17.2
WORKDIR /usr/local/bin
# 可以在构建镜像的时候指定webhook和grafana的地址也可以在部署时通过环境变量传入
ENV WEB_HOOK_URL=""
ENV GRAFANA_URL=""
ENV PROMETHEUS_URL=""
COPY --from=build /tmp/app /usr/local/bin/app
RUN chmod +x /usr/local/bin/app
EXPOSE 80
CMD ["app"]